<template>
  <div class="dlg">
    <el-dialog
      title="新增机构类型"
      :visible="showDlg"
      :show-close="false"
      width="60%"
    >
      机构类别名称：
      <el-input v-model="name" />
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirmAddCategory">添加</el-button>
        <el-button type="warning" @click="$emit('cancle')">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { Dialog, Button, Input } from "element-ui";
import {addOrgCategory} from "@/api/first-loan.js";
export default {
  name: "add-org-dlg",
  components: {
    [Dialog.name]: Dialog,
    [Button.name]: Button,
    [Input.name]: Input
  },
  props: {
    showDlg: Boolean
  },
  data() {
    return {
      name: ''
    };
  },
  methods: {
    confirmAddCategory() {
        addOrgCategory(this.name)
            .then(res => {
                this.name = '';
                this.$emit('confirm');
            })
            .catch(errMsg => this.$alert(errMsg.msg))
    }
  }
};
</script>
<style lang="stylus" scoped>
.el-input{
    width: 200px;
}
</style>